<%--
  Created by IntelliJ IDEA.
  User: DE
  Date: 2019/4/9
  Time: 17:47
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>工单管理</title>
    <link href="<%=basePath%>resources/layui/css/layui.css" rel="stylesheet"></link>
    <link href="<%=basePath%>resources/css/style.css" rel="stylesheet"></link>

    <style>
        .layui-fixbar{
            width: 40px;
        }

    </style>
</head>
<body>
<!-- layout admin -->
<div class="layui-layout layui-layout-admin"> <!-- 添加skin-1类可手动修改主题为纯白，添加skin-2类可手动修改主题为蓝白 -->
    <!-- header -->
    <div class="layui-header my-header">
        <a href="<c:if test="${user.usertype==1}"><%=basePath%>order/orderlist</c:if><c:if test="${user.usertype==0}"><%=basePath%>page/manager/orderManager</c:if>">
            <!--<img class="my-header-logo" src="" alt="logo">-->
            <div class="my-header-logo">校园便捷服务平台</div>
        </a>


        <!-- 顶部右侧添加选项卡监听 -->
        <ul class="layui-nav my-header-user-nav" lay-filter="side-top-right">
            <li class="layui-nav-item"><span id="datetime"></span>&nbsp;</li>
            <li class="layui-nav-item">
                <a href="<c:if test="${user.usertype==1}"><%=basePath%>order/orderlist</c:if><c:if test="${user.usertype==0}"><%=basePath%>page/manager/orderManager</c:if>">主页</a>
            </li>
            <li class="layui-nav-item">
                <a href="<%=basePath%>order/acceptOrderlist">我的订单<!--<span class="layui-badge">9</span>--></a>
            </li>
            <li class="layui-nav-item">
                <a href="<%=basePath%>page/user/personalCenter">个人中心<!--<span class="layui-badge-dot"></span>--></a>
            </li>
            <li class="layui-nav-item">
                <a href="<%=basePath%>page/user/personalCenter"><c:if test="${user.userimg!=null}"><img src="<%=basePath%>${user.userimg}" class="layui-nav-img"></c:if>${user.username}</a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;" onclick="logout()">退出系统</a></dd>
                </dl>
            </li>
        </ul>
        <div class="layui-side my-side">
            <div class="layui-side-scroll">
                <!-- 左侧主菜单添加选项卡监听 -->
                <ul class="layui-nav layui-nav-tree layui-bg-black"  lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed  layui-this">
                        <a  href="<%=basePath%>page/manager/orderManager">工单管理</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="<%=basePath%>page/manager/userManager">人员管理</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="<%=basePath%>page/manager/dataManager">数据统计</a>
                    </li>
                </ul>


            </div>
        </div>
    </div>


    <!-- body -->
    <div class="layui-body my-body"  style="background-color: #F6F6F6">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="width:101%">
                <!-- 工具集 -->
                <div class="my-btn-box">
            <span class="fl">
                <span class="layui-form-label">搜索条件：</span>
                <div class="layui-inline">
                    <input type="text" autocomplete="off" style="width:260px" placeholder="标题，内容，用户名" id="key"
                           name="key" class="layui-input">
                </div>
                <label>时间</label>
        <div class="layui-input-inline">
            <input type="text" id="start_time" name="start_time" autocomplete="off" placeholder="开始时间"
                   class="layui-input">
        </div> 至
        <div class="layui-input-inline">
            <input type="text" id="end_time" name="end_time" autocomplete="off" placeholder="结束时间" class="layui-input">
        </div>

                <button class="layui-btn layui-btn-danger mgl-20" data-type="reload">查询</button>
                <!--<a class="layui-btn btn-default btn-add" id="btn-add-article">添加</a>-->
            </span>
                    <span class="fr">

            </span>
                </div>

                <div id="dateTable" lay-filter="user" style="height: auto;width: 100%"></div>
            </div>
        </div>


    </div>

</div>
 <script type="text/javascript" src="<%=basePath%>resources/jquery-3.2.1/jquery-3.2.1.js" ></script>
 <script src="<%=basePath%>resources/layui/layui.js"></script>
 <script src="<%=basePath%>resources/js/vip_comm.js"></script>
<script src="<%=basePath%>resources/js/vip_table.js"></script>

 <script src="<%=basePath%>resources/js/functionList.js"></script>
 <script type="text/javascript">
     var tableIns;
     // layui方法
     layui.use(['table', 'layer', 'laydate'], function () {
         var treeName;
         var laydate = layui.laydate;
         var endDate = laydate.render({
             type:'date',
             elem: '#end_time',//选择器结束时间
             min: "2018-11-01",//设置min默认最小值
         });
         //日期范围
         var startDate = laydate.render({
             type:'date',
             elem: '#start_time',
             min: "2018-11-01",
             max: "2099-12-31"//设置一个默认最大值
         });
         // 操作对象
         var table = layui.table
             , layer = layui.layer
             , $ = layui.jquery;
         var queryParams = {
             startDate:$("#start_time").val(),
             endDate:$("#end_time").val(),
             key:$("#key").val()

         };

         // 表格渲染
         tableIns = table.render({
             elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
             //, height: vipTable.getFullHeight()    //容器高度
             , cols: [
                 [
                     {field: 'id', title: 'ID',sort:true}
                     ,{field: 'ordernum', title: '订单号',sort:true}
                     , {field: 'ordertitle', title: '标题'}
                     , {field: 'orderbody', title: '内容'}
                     , {field: 'releaseusername', title: '发布用户名'}
                     , {field: 'acceptusername', title: '接受用户名'}
                     , {field: 'payuserid', title: '工单状态',templet: '#channel'}


                     , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barOption',width:160} //这里的toolbar值是模板元素的选择器
                 ]
             ]
             ,defaultToolbar: ['filter', 'print', 'exports']
             , id: 'dataList'
             , url: '<%=basePath%>order/allOrders'
             , method: 'get'
             , page: true
             , limits: [30, 60, 90, 150, 300]
             , limit: 30 //默认采用30
             , loading: false
             , done: function (res, curr, count) {
                 var queryParams = {
                     startDate:$("#start_time").val(),
                     endDate:$("#end_time").val(),
                     key:$("#key").val()

                 };
             }
             ,where:queryParams

         });

         // 获取选中行
         table.on('tool(user)', function (obj) {
             var data = obj.data;
             if (obj.event === 'edit') {

                 layer.open({
                     title: '浏览工单',
                     type: 2,
                     content: "<%=basePath%>order/orderMessage?id="+data.id,
                     area: ['900px', '580px'],
                     end:function () {
                         reloadTable();
                     }

                 });

             }else if (obj.event === 'del') {
                 layer.confirm('确认删除?', {icon: 3, title:'提示'}, function(index) {
                     $.ajax({
                         type: "get",
                         url: "<%=basePath%>order/deleteOrder",
                         data: {'id':data.id},
                         success: function (data) {
                             layer.msg(data.msg);
                             obj.del();

                         }


                     });
                 });
             }
         });
         var $ = layui.$, active = {
             reload: function () {
                 var k = $('#key');
                 var startDate = $("#start_time").val();
                 var endDate = $("#end_time").val();
                 //执行重载
                 tableIns.reload({
                     page: {
                         curr: 1 //重新从第 1 页开始
                     }
                     , where: {
                         key: k.val(),
                         startDate:startDate,
                         endDate:endDate

                     }
                 });
             }
         };

         $('.my-btn-box .layui-btn').on('click', function () {
             //alert(1)
             var type = $(this).data('type');
             active[type] ? active[type].call(this) : '';
         });


     });

     function reloadTable() {
         tableIns.reload('dataList', {page: {curr: 1}});
     }


    /**
     * 显示时间
     * */
     writeDateInfo();


 </script>
<script type="text/html" id="channel">
    {{#  if(d.accpetstatus==0) { }}
    <a class="layui-btn layui-btn-mini" style="background-color: #009688;">待接受</a>
    {{#  }else if(d.accpetstatus==1 && d.finishstatus==0){  }}
    <a class="layui-btn layui-btn-mini" style="background-color: #5FB878;">进行中</a>
    {{#  }else if(d.finishstatus==1 && d.commentstatus==0){  }}
    <a class="layui-btn layui-btn-mini" style="background-color: #1E9FFF;">未评论</a>
    {{#  }else if(d.commentstatus==1){  }}
    <a class="layui-btn layui-btn-mini" style="background-color: #FFB800;">已完成</a>
    {{#  }else if(d.commentstatus==2){  }}
    <a class="layui-btn layui-btn-mini " style="background-color: #FF5722;">投诉</a>
    {{# } else { }}
    ？？？
    {{# } }}
</script>
<!-- 表格操作按钮集 -->
<script type="text/html" id="barOption">
    <a class="layui-btn layui-btn-mini layui-btn-normal" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-mini layui-btn-danger" lay-event="del">删除</a>
</script>
</body>
</html>
